home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
program
/
363
/
xprolog2
/
nrev
< prev
next >
Wrap
Text File
|
1985-11-19
|
593b
|
29 lines
/* Naive Reverse Benchmark */
nrev:- write('list length: '),
read(X),
conslist(X, List),
T1 is cputime,
nreverse(List, R),
T2 is cputime,
T is T2 - T1,
I is (X*(X+3))/2 + 1,
LIPS is (I*1000)/T,
write('LIPS= '),
write(LIPS),
write(' in '), write(T), write(' msec.'),
nl,!.
nreverse([], []).
nreverse([X|L0],L) :- nreverse(L0, L1),
concat(L1, [X], L).
conslist(0, []) :- !.
conslist(N, [N|L]) :-
N1 is N-1,
conslist(N1, L).
concat([],L,L). % common append procedure
concat([X|L1],L2,[X|L3]) :- concat(L1,L2,L3).